package com.cwiyc.orderonlineback.mapper;

import com.cwiyc.orderonlineback.entity.Meal;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface MealMapper {

    @Select("select * from mealsort where msid=#{msid} and mstatus=1")
    List<Meal> getmeal(Integer msid);

    @Update("update meal set mstock=mstock-1,msales=msales+1 where mid = #{odmid}")
    int updatess(Integer odmid);

    @Update("update meal set mstatus=0 where mid = #{mid}")
    int deletemeal(Integer mid);

    @Insert("insert into meal (mname,mintro,mpic,mprice,mstock,msales,mstatus,mtype,msid) values (#{mname},#{mintro},#{mpic},#{mprice},#{mstock},#{msales},#{mstatus},#{mtype},#{msid})")
    int insertmeal(String mname, String mintro, String mpic, String mprice, Integer mstock, Integer msales, Integer mstatus, String mtype, Integer msid);

    @Update("update meal set mname=#{mname},mintro=#{mintro},mpic=#{mpic},mprice=#{mprice},mstock=#{mstock},msales=#{msales},mstatus=#{mstatus},mtype=#{mtype},msid=#{msid} where mid=#{mid}")
    int modeifymeal(Integer mid, String mname, String mintro, String mpic, String mprice, Integer mstock, Integer msales, Integer mstatus, String mtype, Integer msid);

    @Select("select mid,mintro,mpic,mname,mprice,mstock,msales,mtype,msid,mstatus from mealsort,shop where mealsort.msid=shop.sid and mstatus=1 and ssixcode=#{code}")
    List<Meal> getmealbycode(String code);

}

